#!/bin/sh


curl -stderr "http://www.socialpicks.com/channel"|dos2unix  |egrep  -A 25  "\(<a href=\"/stock/[A-Z]+\">[A-Z]+</a>\)$" |egrep -o ">[A-Z]+<|Rating: [A-Z]+|noHoverLink' href='/[A-Za-z0-9_.]+'" |sed 's/<//g' |tr '\n' ' '|tr '>' '\n' |sed 's/Rating:/,/g'|egrep "," |sed -e "s/noHoverLink//g" -e 's/href=//g' -e "s/'//g" -e 's/\//,/g'  > tmp$$

echo "#Stock Rating Score Return Winning Member"  > SocialPickList
cat tmp$$ |while read line
do
  stock=`echo $line |cut -d',' -f1`
  recommend=`echo $line |cut -d',' -f2`
  member=`echo $line |cut -d',' -f3`
  #accuracy=`curl -stderr "http://www.socialpicks.com/$member" |grep -A 7 "Accuracy:" |egrep -o "[0-9]+.[0-9]+%"`
  score=`curl -stderr "http://www.socialpicks.com/$member" |grep -A 7 ">Score <" |grep lightBlack |egrep -o "[0-9]+.[0-9]+" |head -n 1`
  avgreturn=`curl -stderr "http://www.socialpicks.com/$member" |grep -A 7 "Return" |egrep -o "[0-9]+.[0-9]+%" |head -n 1`
  winning=`curl -stderr "http://www.socialpicks.com/$member" |grep -A 3 "Winning Picks"  |egrep -o "[0-9]+%"`
  #return=`curl -stderr "http://www.socialpicks.com/$member"" |grep -A 7 "Avg Return" |egrep -o "[+|-][0-9]+.[0-9]+%"`
  #echo -e "$stock\t,$recommend\t,$accuracy\t\t,$avgreturn\t\t,$member" >> SocialPickList
  echo  $stock $recommend $score $avgreturn $winning $member >> SocialPickList
 
done

cat SocialPickList |awk '{printf("%s\t%s\t%s\t%s\t%s\t\n"),$1,$2,$3,$4,$5}'
